package com.shuyun.config;

import java.util.Collections;
import java.util.List;

import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import com.alibaba.fastjson2.support.spring.http.converter.FastJsonHttpMessageConverter;

/**
 * @description: MVC配置处理器
 * @author: shuai.chen@shuyun.com
 * @date: 2022/10/9 3:09 PM
 **/
@Configuration
public class SelfWebMvcConfig extends WebMvcConfigurationSupport {

    /**
     * Override this method to extend or modify the list of converters after it has been configured. This may be useful
     * for example to allow default converters to be registered and then insert a custom converter through this method.
     *
     * @param converters
     *            the list of configured converters to extend
     * @since 4.1.3
     */
    @Override
    protected void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
        FastJsonHttpMessageConverter fastJsonHttpMessageConverter = new FastJsonHttpMessageConverter();
        fastJsonHttpMessageConverter.setSupportedMediaTypes(Collections.singletonList(MediaType.APPLICATION_JSON));
        converters.add(fastJsonHttpMessageConverter);
    }
}
